*** Settings ***
Resource          ../resources/vehicle_control.resource
Resource          ../resources/adb_keywords.resource
Resource          ../resources/canoe_keyword.resource

*** Variables ***
${CANOE_CONFIG_PATH}    C:\\path\\to\\your\\canoe_config.cfg    # 替换为你的CANoe配置文件路径
${SIGNAL_NAME_1}    Signal1    # 替换为第一个信号名称
${SIGNAL_NAME_2}    Signal2    # 替换为第二个信号名称
${SIGNAL_NAME_3}    Signal3    # 替换为第三个信号名称
${EXPECTED_SIGNAL_VALUE_1}    42    # 替换为第一个信号的预期值
${EXPECTED_SIGNAL_VALUE_2}    43    # 替换为第二个信号的预期值
${EXPECTED_SIGNAL_VALUE_3}    44    # 替换为第三个信号的预期值
${IMAGE_PATH_A}    path/to/image_a.png  # 正常进入AVM界面的原始图片存放位置
${IMAGE_PATH_C}    path/to/image_c.png  # 正常AVM界面的原始图片存放位置
${QUIT_360_DEVICE_AUDIO_PATH}    /sdcard/audio/file.mp3  #提前录制的语音退出AVM
${LANGUAGE}    chi_sim  # 可选语言代码，例如 'eng' 或 'chi_sim'
${START_X}   Start_X  # 替换为滑屏起点X坐标
${START_Y}   Start_Y  # 替换为滑屏起点Y坐标
${END_X}     End_X    # 替换为滑屏终点X坐标
${END_Y}     End_Y    # 替换为滑屏终点Y坐标
${DURATION}     Duration    # 替换为滑屏chi
*** Test Cases ***
ID_037
        [Documentation]    利用CAN信号读取初始状态，如果满足，就执行step1,如果不满足，则终止此轮测试
        ...                利用滑屏进入AVM，然后进行第一次比图
        ...                利用360APP按键退出AVM，然后进行第二次比图
        ...                输出第一次比图和第二次比图的结果
        [Setup]    初始化CANoe  ${CANOE_CONFIG_PATH}
        启动 CANoe 应用程序
        Sleep    10s
        加载 CANoe 配置
        Sleep    10s
        启动 CANoe 测量
        Sleep    10s
        #获取第一个信号的值
        ${signal_value_1}=   获取信号值    ${SIGNAL_NAME_1}
        Log    Signal ${SIGNAL_NAME_1} value: ${signal_value_1}
        Should Be Equal As Strings    ${signal_value_1}  ${EXPECTED_SIGNAL_VALUE_1}
        Sleep    10s
        #获取第二个信号的值
        ${signal_value_2}=  获取信号值    ${SIGNAL_NAME_2}
        Log    Signal ${SIGNAL_NAME_2} value: ${signal_value_2}
        Should Be Equal As Strings    ${signal_value_2}  ${EXPECTED_SIGNAL_VALUE_2}
        Sleep    10s
        #获取第三个信号的值
        ${signal_value_3}=  获取信号值    ${SIGNAL_NAME_3}
        Log    Signal ${SIGNAL_NAME_3} value: ${signal_value_3}
        Should Be Equal As Strings    ${signal_value_3}  ${EXPECTED_SIGNAL_VALUE_3}
        Sleep    10s
        
        # 滑屏进入AVM
        滑屏    ${START_X}    ${START_Y}    ${END_X}    ${END_Y}    ${DURATION}

        #比较两个图像
        [Documentation]    测试两张图片的相似性
        [Tags]    ImageComparison

        #定义两张图片的路径
        ${image_path_b}  Set Variable    path/to/image_b.png
        
        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_a}  ${image_path_b}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        # 根据比较结果终止测试
    
        [Documentation]    测试根据resource-id点击图标的功能,推出AVM
        [Tags]    ADB

        #调用关键字，传入目标元素的resource-id
        根据ID点击图标    resource-id="your_element_resource_id"
        #比较两个图像        根据ID点击图标

        #定义两张图片的路径
        ${image_path_d}  Set Variable    path/to/image_d.png
        
        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_c}  ${image_path_d}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        停止 CANoe 测量
    
        Sleep    10s
    
        关闭 CANoe 应用程序
    
        Sleep    10s

ID_038
        [Documentation]    利用CAN信号读取初始状态，如果满足，就执行step1,如果不满足，则终止此轮测试
        ...                利用滑屏进入AVM，然后进行第一次比图
        ...                利用方向盘多功能按键退出AVM，然后进行第二次比图
        ...                输出第一次比图和第二次比图的结果
        [Setup]    初始化CANoe  ${CANOE_CONFIG_PATH}
        启动 CANoe 应用程序
        Sleep    10s
        加载 CANoe 配置
        Sleep    10s
        启动 CANoe 测量
        Sleep    10s
        #获取第一个信号的值
        ${signal_value_1}=   获取信号值    ${SIGNAL_NAME_1}
        Log    Signal ${SIGNAL_NAME_1} value: ${signal_value_1}
        Should Be Equal As Strings    ${signal_value_1}  ${EXPECTED_SIGNAL_VALUE_1}
        Sleep    10s
        #获取第二个信号的值
        ${signal_value_2}=  获取信号值    ${SIGNAL_NAME_2}
        Log    Signal ${SIGNAL_NAME_2} value: ${signal_value_2}
        Should Be Equal As Strings    ${signal_value_2}  ${EXPECTED_SIGNAL_VALUE_2}
        Sleep    10s
        #获取第三个信号的值
        ${signal_value_3}=  获取信号值    ${SIGNAL_NAME_3}
        Log    Signal ${SIGNAL_NAME_3} value: ${signal_value_3}
        Should Be Equal As Strings    ${signal_value_3}  ${EXPECTED_SIGNAL_VALUE_3}
        Sleep    10s
        
        # 滑屏进入AVM
        滑屏    ${START_X}    ${START_Y}    ${END_X}    ${END_Y}    ${DURATION}

        #比较两个图像
        [Documentation]    测试两张图片的相似性
        [Tags]    ImageComparison

        #定义两张图片的路径
        ${image_path_b}  Set Variable    path/to/image_b.png
        
        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_a}  ${image_path_b}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        # 根据比较结果终止测试

        点击开关进入AVM

        #比较两个图像        根据ID点击图标

        #定义两张图片的路径
        ${image_path_d}  Set Variable    path/to/image_d.png
        
        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_c}  ${image_path_d}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        停止 CANoe 测量
    
        Sleep    10s
    
        关闭 CANoe 应用程序
    
        Sleep    10s

ID_039
        [Documentation]    利用CAN信号读取初始状态，如果满足，就执行step1,如果不满足，则终止此轮测试
        ...                利用滑屏进入AVM，然后进行第一次比图
        ...                语音退出AVM，然后进行第二次比图
        ...                输出第一次比图和第二次比图的结果
        [Setup]    初始化CANoe  ${CANOE_CONFIG_PATH}
        启动 CANoe 应用程序
        Sleep    10s
        加载 CANoe 配置
        Sleep    10s
        启动 CANoe 测量
        Sleep    10s
        #获取第一个信号的值
        ${signal_value_1}=   获取信号值    ${SIGNAL_NAME_1}
        Log    Signal ${SIGNAL_NAME_1} value: ${signal_value_1}
        Should Be Equal As Strings    ${signal_value_1}  ${EXPECTED_SIGNAL_VALUE_1}
        Sleep    10s
        #获取第二个信号的值
        ${signal_value_2}=  获取信号值    ${SIGNAL_NAME_2}
        Log    Signal ${SIGNAL_NAME_2} value: ${signal_value_2}
        Should Be Equal As Strings    ${signal_value_2}  ${EXPECTED_SIGNAL_VALUE_2}
        Sleep    10s
        #获取第三个信号的值
        ${signal_value_3}=  获取信号值    ${SIGNAL_NAME_3}
        Log    Signal ${SIGNAL_NAME_3} value: ${signal_value_3}
        Should Be Equal As Strings    ${signal_value_3}  ${EXPECTED_SIGNAL_VALUE_3}
        Sleep    10s

        # 滑屏进入AVM
        滑屏    ${START_X}    ${START_Y}    ${END_X}    ${END_Y}    ${DURATION}

        #比较两个图像
        [Documentation]    测试两张图片的相似性
        [Tags]    ImageComparison

        #定义两张图片的路径
        ${image_path_b}  Set Variable    path/to/image_b.png

        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_a}  ${image_path_b}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        # 根据比较结果终止测试

        在设备上播放语音文件
        [Documentation]    测试在设备上播放语音文件
        在设备上播放语音文件    ${QUIT_360_DEVICE_AUDIO_PATH}

        #比较两个图像        根据ID点击图标

        #定义两张图片的路径
        ${image_path_d}  Set Variable    path/to/image_d.png

        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_c}  ${image_path_d}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        停止 CANoe 测量

        Sleep    10s

        关闭 CANoe 应用程序

        Sleep    10s
ID_040
        [Documentation]    Not available
ID_041
        [Documentation]    利用CAN信号读取初始状态，如果满足，就执行step1,如果不满足，则终止此轮测试
        ...                利用滑屏进入VM，然后进行第一次比图
        ...                点击屏幕home键，退出AVM，然后进行第二次比图
        ...                输出第一次比图和第二次比图的结果
        [Setup]    初始化CANoe  ${CANOE_CONFIG_PATH}
        启动 CANoe 应用程序
        Sleep    10s
        加载 CANoe 配置
        Sleep    10s
        启动 CANoe 测量
        Sleep    10s
        #获取第一个信号的值
        ${signal_value_1}=   获取信号值    ${SIGNAL_NAME_1}
        Log    Signal ${SIGNAL_NAME_1} value: ${signal_value_1}
        Should Be Equal As Strings    ${signal_value_1}  ${EXPECTED_SIGNAL_VALUE_1}
        Sleep    10s
        #获取第二个信号的值
        ${signal_value_2}=  获取信号值    ${SIGNAL_NAME_2}
        Log    Signal ${SIGNAL_NAME_2} value: ${signal_value_2}
        Should Be Equal As Strings    ${signal_value_2}  ${EXPECTED_SIGNAL_VALUE_2}
        Sleep    10s
        #获取第三个信号的值
        ${signal_value_3}=  获取信号值    ${SIGNAL_NAME_3}
        Log    Signal ${SIGNAL_NAME_3} value: ${signal_value_3}
        Should Be Equal As Strings    ${signal_value_3}  ${EXPECTED_SIGNAL_VALUE_3}
        Sleep    10s

        # 滑屏进入AVM
        滑屏    ${START_X}    ${START_Y}    ${END_X}    ${END_Y}    ${DURATION}

        #比较两个图像
        [Documentation]    测试两张图片的相似性
        [Tags]    ImageComparison

        #定义两张图片的路径
        ${image_path_b}  Set Variable    path/to/image_b.png

        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_a}  ${image_path_b}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        # 根据比较结果终止测试

        [Documentation]    测试根据resource-id点击图标的功能
        [Tags]    ADB

        #调用关键字，传入目标元素的resource-id
        根据ID点击图标    resource-id="your_element_resource_id"

        #比较两个图像
        [Documentation]    测试两张图片的相似性
        [Tags]    ImageComparison

        #比较两个图像        根据ID点击图标

        #定义两张图片的路径
        ${image_path_d}  Set Variable    path/to/image_d.png

        #调用关键字比较图像
        ${mse}  ${ssim}  比较图像    ${image_path_c}  ${image_path_d}

        #打印结果
        Log    MSE: ${mse}, SSIM: ${ssim}

        停止 CANoe 测量

        Sleep    10s

        关闭 CANoe 应用程序

        Sleep    10s